﻿#region COPYRIGHT
//--------------------------------------------------------------------------------
// <copyright file="ToolStripItem.cs" company="starLiGHT Entertainment Studios">
//    Copyright (c) 2011 
//       Roland Rosenkranz (Glatzemann@email.de)
// </copyright>
// <license>
//   This file is part of starLiGHT.GUI.
//
//   It is released under the Microsoft Public License (Ms-PL).
//
//   You should have received a copy of the Microsoft Public License
//   along with starLiGHT.GUI. If not, see http://sle.codeplex.com/license.
//    
//   ADDITIONAL (commercial) LICENSES for starLiGHT.GUI are available on request.
// </license>
// <version>
// **************[ starLiGHT.Engine SVN ]**********************
// * $Rev:: 9926                  $:  Revision of last commit *
// * $Author:: unknown            $:  Author of last commit   *
// * $Date:: 2011-05-10 19:07:29 #$:  Date of last commit     *
// ************************************************************
// </version>
//--------------------------------------------------------------------------------
#endregion

namespace starLiGHT.GUI.Widgets
{
    #region Using Statements
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Xna.Framework;
    #endregion

    public abstract class ToolStripItem
    {
        #region Private Members
        private string text;
        private Vector2 offset;
        #endregion

        #region Constructors
        public ToolStripItem()
        {
        }

        public ToolStripItem(string text)
        {
            this.text = text;
        }
        #endregion

        #region Events
        /// <summary>
        /// Occurs when the item is clicked
        /// </summary>
        public event EventHandler Click;

        #endregion

        public string Text
        {
            get
            {
                return this.text;
            }

            set
            {
                this.text = value;
            }
        }

        public ToolStrip ToolStrip
        {
            get;
            internal set;
        }

        public virtual bool Focus
        {
            get;
            set;
        }

        public virtual Vector2 Offset
        {
            get
            {
                return this.offset;
            }

            set
            {
                this.offset = value;
            }
        }

        public virtual Vector2 Size
        {
            get
            {
                return ToolStrip.Manager.DefaultFont.MeasureString(this.Text);
            }
        }

        public abstract void Draw(GameTime gameTime, IGuiRenderer renderer, ToolStrip toolStrip, ref Vector2 offset);

        public virtual void OnClick(object sender, System.EventArgs e)
        {
            if (this.Click != null)
            {
                this.Click(sender, e);
            }
        }

        public virtual RectangleF GetHitTestRectangle()
        {
            return new RectangleF(this.Offset, this.Size);
        }
    }
}
